lisp/editorconfig: Don't hook into `read-only-mode-hook`
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 12 Jun 2024 22:27:15 +0000 (18:27 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 19 Jun 2024 18:39:17 +0000 (14:39 -0400)
commit527a45abc37f1885652b0f29ed5eeabff6db6cda
treec6160f9a8f3855dc2a1867ddb4de85495439caf0
parent25523847e7931de1f0ee638d2a8847d979fdb496
lisp/editorconfig: Don't hook into `read-only-mode-hook`

Don't re-set variables just because `read-only-mode` is (de)activated,
and with Emacs-30's hooks it would be even less natural to do.
Also `buffer-read-only` can change without calling `read-only-mode`,
so better test it dynamically when we try to trim whitespace.

* lisp/editorconfig.el (editorconfig--delete-trailing-whitespace):
New function.
(editorconfig-set-trailing-ws): Use it.  Use `pcase`.
Also prefer `before-save-hook` and use `add/remove-hook` to
manipulate hooks, like god intended.
Don't test `buffer-read-only` any more.
(editorconfig-mode): Don't hook into `read-only-mode-hook` any more.
lisp/editorconfig.el